//
//  GoalPickerAndUnitView.swift
//  DaRings
//
//  Created by 魔样科技 on 2022/11/12.
//

import Foundation
import MYModule

class GoalSetupPickerAndUnitView: View {
    
    private var didSelectClosure: ((Int) -> ())?
    
    override func makeUI() {
        super.makeUI()
        
        self.addSubview(self.unitLabel)
        self.unitLabel.snp.makeConstraints { make in
            make.trailing.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        
        self.addSubview(self.pickerView)
        self.pickerView.snp.makeConstraints { make in
            make.trailing.equalTo(self.unitLabel.snp.leading)
            make.width.equalTo(100)
            make.height.equalTo(60)
            make.centerY.equalToSuperview()
            make.top.leading.equalToSuperview()
        }
        
    }
    
    public func updatePickerFrame(_withWidth width:Float) {
        self.pickerView.snp.updateConstraints { make in
            make.width.equalTo(width)
        }
    }
    
    
    public func returnDidSelectClosure(_ closure: @escaping (Int) -> ()) {
        self.didSelectClosure = closure
    }
    
    //MARK: - lazy load -
    
    public lazy var pickerView: GoalSetupPickerView = {
        let pickerView = GoalSetupPickerView()
        return pickerView
    }()
    
    public lazy var unitLabel: Label = {
        let label = Label()
        label.textColor = UIColor.theme
        label.font = Fonts.systemFont(ofSize: 16)
        return label
    }()
}
